from playwright.sync_api import sync_playwright  # 导入同步API:cite[1]


def main():
    with sync_playwright() as p:  # 启动Playwright
        # 启动浏览器（headless=False表示显示浏览器界面，默认为True无头模式）
        browser = p.chromium.launch(headless=False)
        page = browser.new_page()  # 创建一个新页面
        page.goto("https://baidu.com")  # 导航到目标网址


        # 打印页面标题
        print(f"页面标题: {page.title()}")

        # 关闭浏览器
        browser.close()


if __name__ == "__main__":
    main()